{{include file="public/header.php"/}}
<ol class="breadcrumb">
	<li>
		<span class="glyphicon glyphicon-home"></span>
		<a href="{{U('Cms/Index/welcome')}}">首页</a>
	</li>
	<li>修改模型</li>
</ol>
<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<div class="alert alert-success" style="border:solid 1px #27ae60;">
				请仔细填写，否则影响系统使用
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="main-box">
				<header class="main-box-header clearfix">
					<h2>修改模型</h2>
				</header>
				<div class="main-box-body clearfix">
					<form role="form" onsubmit="return update({{$field['mid']}});">
						<input type="hidden" name="mid" value="{{$field['mid']}}">
						<div class="form-group">
							<label for="model_name">模型名称</label>
							<input type="text" name="model_name" value="{{$field['model_name']}}" required class="form-control" id="model_name">
						</div>
						<div class="form-group">
							<label for="table_name">表名</label>
							<input type="text" name="table_name" value="{{$field['table_name']}}" required class="form-control" id="table_name">
						</div>
						<div class="form-group">
							<label for="model_description">描述</label>
							<textarea name="model_description" required class="form-control" id="model_description" rows="5">{{$field['model_description']}}</textarea>
						</div>
						<div class="form-group">
							<label>前台投稿</label>
							<div class="radio">
								<input type="radio" name="contribute" id="contribute1" value="1"
								{{if value="$field['contribute']==1"}}
								checked=""
								{{/if}}>
								<label for="contribute1">
									是
								</label>
							</div>
							<div class="radio">
								<input type="radio" name="contribute" id="contribute2" value="0" 
								{{if value="$field['contribute']==0"}}
								checked=""
								{{/if}}>
								<label for="contribute2">
									不是
								</label>
							</div>
						</div>
						<div>
							<button type="submit" class="btn btn-primary btn-xm">
								更新模型
							</button>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

{{include file="public/footer.php"/}}

<script>
	function update(mid)
	{
		$.ajax({
			url: '/cms/model/'+mid,
			data: $('form').serialize(),
			type: 'PUT',
			dataType: 'JSON',
			success:function(result)
			{
				if(result.code==0)
				{
					dialog(result.message,'success',1000,function()
					{
						location.href="/cms/model"
					});
				}
				else
				{
					dialog(result.message,'error',1000);    
				}
			}
		})
		return false;
	}
</script>